package de.stefanocke.roo.wicket.templates

import org.apache.felix.scr.annotations.Component
import org.apache.felix.scr.annotations.Reference
import org.apache.felix.scr.annotations.Service
import org.springframework.roo.process.manager.FileManager
import org.springframework.roo.project.LogicalPath
import org.springframework.roo.project.ProjectOperations

@Component
@Service
class TemplateSupportServiceImpl implements TemplateSupportService{
	@Reference
	ProjectOperations projectOperations
	@Reference
	FileManager fileManager

	override createFile(LogicalPath basePath, String relativePath, CharSequence contents){
		if(contents!=null){
			val fid = pathResolver.getIdentifier(basePath, relativePath)
			fileManager.createOrUpdateTextFileIfRequired(fid, contents.toString, true)	
		}
	}
	
	def pathResolver(){
		projectOperations.pathResolver
	}
	
}